#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int c, m, n;
int cnt;
const int N = 110;
struct S
{
	int a, b, w;
}s[N];
int f[N];
int find(int x)	
{
	if (x != f[x]) {
		f[x] = find(f[x]);
	}
	return f[x];
}
int cmp(S a, S b)
{
	return a.w < b.w;
}

int kruskal()
{
	sort(s, s + m, cmp);
	int res = 0;
	for (int i = 1; i <= n; i++) {
		f[i] = i;
	}
	for (int i = 0; i < m; i++) {
		int a = s[i].a;
		int b = s[i].b;
		int w = s[i].w;
		int pa = find(a);
		int pb = find(b);
		if (pa != pb) {
			f[pa] = pb;
			res += w;
		}
	}
	return res;
}
int main()
{
	while (cin >> c >> m >> n) {
		memset(f, 0, sizeof(f));
		memset(s, 0, sizeof(s));
		int a, b, w;
		cnt = 0;
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> w;
			s[i] = { a,b,w };
		}
		int ret = kruskal();
		if (ret <= c) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}	